﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _10_自定义_泛型委托
{
    public delegate void DelSwap<T>(ref T a, ref T b);

    internal class Program
    {
        static void Main(string[] args)
        {
            DelSwap<int> delint = new DelSwap<int>(Swap);

            int a = 10;
            int b = 20;

            //提示交换前
            Console.WriteLine("交换前：a={0},b={1}", a, b);

            //调用委托
            delint(ref a, ref b);

            //提示交换后
            Console.WriteLine("交换后：a={0},b={1}", a, b);

            Console.Read();
        }

        public static void Swap(ref int a,ref int b)
        {
            int temp = a;
            a = b;
            b = temp;
        }
    }
}
